{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-02-10T07:43:47.959404Z",
     "start_time": "2020-02-10T07:43:47.954419Z"
    }
   },
   "outputs": [],
   "source": [
    "def Y(n):\n",
    "    d = 0.001\n",
    "    num_dingdian = 2**n # n维立方体顶点数\n",
    "    num_leng = n * 2**(n-1) # n维立方体棱数\n",
    "    num_chonghe = n - 1 # 顶点处重复计算的\n",
    "    y = d**(n-1) * num_leng - d**n * num_dingdian * num_chonghe\n",
    "    return num_dingdian, num_leng, y*100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-02-10T07:43:48.141916Z",
     "start_time": "2020-02-10T07:43:48.135965Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(4, 4, 0.39960000000000007)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Y(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-02-10T07:43:48.488988Z",
     "start_time": "2020-02-10T07:43:48.484002Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(8, 12, 0.0011984)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Y(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-02-10T07:43:48.753285Z",
     "start_time": "2020-02-10T07:43:48.748295Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(16, 32, 3.1952e-06)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Y(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-02-10T08:45:11.987967Z",
     "start_time": "2020-02-10T08:45:11.982980Z"
    }
   },
   "outputs": [],
   "source": [
    "def Y(n):\n",
    "    d = 0.001\n",
    "    num_mian = 2*n # n维立方体边界数\n",
    "    num_dingdian = 2**n # n维立方体顶点数\n",
    "    num_leng = n * 2**(n-1) # n维立方体棱数\n",
    "    num_chongfu = num_leng - 1 # 棱出重复计算的，边界和边界之间两两相交，\n",
    "    y = num_mian * d - num_chongfu * (d ** 2)\n",
    "    return num_dingdian, num_leng, y*100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-02-10T08:45:23.786323Z",
     "start_time": "2020-02-10T08:45:23.780304Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(4, 4, 0.39969999999999994)"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Y(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-02-10T08:45:34.303579Z",
     "start_time": "2020-02-10T08:45:34.298591Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(8, 12, 0.5989)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Y(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-02-10T08:45:42.983603Z",
     "start_time": "2020-02-10T08:45:42.978619Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(16, 32, 0.7969)"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Y(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-02-10T08:45:56.326415Z",
     "start_time": "2020-02-10T08:45:56.322425Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1024, 5120, 1.4881000000000002)"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Y(10)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "nbTranslate": {
   "displayLangs": [
    "*"
   ],
   "hotkey": "alt-t",
   "langInMainMenu": true,
   "sourceLang": "en",
   "targetLang": "fr",
   "useGoogleTranslate": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
